import { createSlice } from '@reduxjs/toolkit'

const initialState = {
  collapsed: false,
  theme: 'light',
  breadcrumbs: [],
}

const appSlice = createSlice({
  name: 'app',
  initialState,
  reducers: {
    toggleCollapsed: (state) => {
      state.collapsed = !state.collapsed
    },
    setCollapsed: (state, action) => {
      state.collapsed = action.payload
    },
    setTheme: (state, action) => {
      state.theme = action.payload
    },
    setBreadcrumbs: (state, action) => {
      state.breadcrumbs = action.payload
    },
  },
})

export const { toggleCollapsed, setCollapsed, setTheme, setBreadcrumbs } = appSlice.actions
export default appSlice.reducer
